Skip to content

Remove Commons Lang 2 usage#2023

Open
gbhat618 wants to merge 2 commits into
jenkinsci:masterfrom
gbhat618:commons-lang2-removal
Open

Remove Commons Lang 2 usage#2023
gbhat618 wants to merge 2 commits into
jenkinsci:masterfrom
gbhat618:commons-lang2-removal

Conversation

@gbhat618

@gbhat618 gbhat618 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Jenkins core is removing commons-lang2 dependency - jenkinsci/jenkins#26105. This project is using lang2 transitively, needing to drop those usages. Instead of migrating and depending on commons-lang3-api, due to the simple usages, this PR migrates to JDK apis.

Testing

$ grep -rn 'import org\.apache\.commons\.lang[.;]' --include='*.java' src/
Exit code: 1
$ mvn clean test-compile -DskipTests -Dban-commons-lang-2.skip=false
[INFO] BUILD SUCCESS
[INFO] Total time:  8.115 s
$ mvn clean compile spotbugs:check -DskipTests -Dban-commons-lang-2.skip=false
[INFO] Done SpotBugs Analysis....
[INFO] BUILD SUCCESS
[INFO] Total time:  12.231 s

gbhat618 and others added 2 commits July 15, 2026 13:32
Jenkins core is dropping commons-lang:2.6 (jenkinsci/jenkins#26905); replace
all 16 affected source files with plain Java 21 equivalents. No new library
dependencies introduced — every call replaced with a JDK 21 idiom.

The one double-getter (EC2SSHLauncher.getOfflineCauseReason()) is cached
in a local to satisfy the SpotBugs NP_NULL rule. Regression guard added to
pom.xml: <ban-commons-lang-2.skip>false</ban-commons-lang-2.skip>.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gbhat618 gbhat618 changed the title BEE-69470: Remove Commons Lang 2 (org.apache.commons.lang) usage BEE-69470: Remove Commons Lang 2 usage Jul 15, 2026
@gbhat618
gbhat618 marked this pull request as ready for review July 15, 2026 10:48

@jglick jglick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK from a quick read.

@apuig apuig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thoughtful cleanup.
I’m waiting for your comments on deleteWhitespace before approving.

Comment on lines -148 to +147
byte[] cipherText = Base64.getDecoder().decode(StringUtils.deleteWhitespace(encodedPassword));
byte[] cipherText = Base64.getDecoder().decode(encodedPassword.replaceAll("\\s+", ""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed the impl of deleteWhitespace is quite different than a regex replacement. I'm tempted to suggest inlining ~15LoC to avoid surprises

@gbhat618 gbhat618 changed the title BEE-69470: Remove Commons Lang 2 usage Remove Commons Lang 2 usage Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants